//
// Created by lz on 2021/2/24.
//

#ifndef MYWEBLIB_BASE_COUNTDOWNLATCH_H_
#define MYWEBLIB_BASE_COUNTDOWNLATCH_H_

#include "base/Condition.h"
#include "base/Mutex.h"

namespace lzweb
{
	class CountDownLatch : noncopyable
	{
	 public:
		explicit CountDownLatch(int count);

		void wait();

		void countDown();

		int getCount() const;

	 private:
		mutable MutexLock mutex_;
	 	Condition condition_ GUARDED_BY(mutex_);
	 	int count_ GUARDED_BY(mutex_);
	};
}// namespace lzweb

#endif //MYWEBLIB_BASE_COUNTDOWNLATCH_H_
